import request from '../utils/request';
import { createTheURL } from '../utils/utils';
import API from '../config/api';


// 添加商品进入购物车
export async function addCar(params) {
  return request(createTheURL(API.API.carAPI, 'add'), {
    method: 'POST',
    body: params,
  });
}

// 删除购物车记录

export async function delCarAll(params) {
  return request(createTheURL(API.API.carAPI, 'delAll'), {
    method: 'DELETE',
    body: params,
  });
}
// 删除商品

export async function delCarGoods(params) {
  return request(createTheURL(API.API.carAPI, 'delgoods'), {
    method: 'DELETE',
    body: params,
  });
}
// 修改商品的数量
export async function editCar(params) {
  return request(createTheURL(API.API.carAPI, 'edit'), {
    method: 'PUT',
    body: params,
  });
}
// 获取当前用户的购物车列表
export async function getCarList(params) {
  return request(createTheURL(API.API.carAPI, 'list'), {
    method: 'POST',
    body: {
      ...params,
    },
  });
}
export async function getCarAllList(params) {
  return request(createTheURL(API.API.carAPI, 'listAll'), {
    method: 'POST',
    body: {
      ...params,
    },
  });
}
